/*/ seating plan logic for event ticketing system
var location_cd = 0;
var max_tickets = 0;
var seatEmpty="/picture/AvailableSeat.gif";
var seatSelected="/picture/SelectedSeat.gif";
var adult_price = 0;
var child_price = 0;
var temp_adult_price = 0;
var temp_child_price = 0;
var adult_tax = 0;
var child_tax = 0;
var senior_price = 0;
var student_price = 0;
var booking_fee = 0.0;
var promo_fee = 0.0;
var show_date = "31-DEC-2003";
var show_time ="0000";
var hasSelector=false;

var  total_num_tickets=0;
var  seats_selected="";
var  adult_num_tickets=0;
var  child_num_tickets=0;
var  senior_num_tickets=0;
var  student_num_tickets=0;
var total_cost=0;

// change the display image
function changepic(img_name,img_src) {
    document[img_name].src=img_src;
}

// sets relevant items
function setShowDate(date){
    show_date = date;
}
function setShowTime(time1){
    show_time = time1;
}
function setAdultTax(tax){
    adult_tax = tax;
}
function setChildTax(tax){
    child_tax = tax;
}
function setHasSelector(boo)
{
    hasSelector=boo;
}
function setMaxTickets(n)
{
    max_tickets=n;
}
function setLocation_cd(lcd)
{
    location_cd=lcd;
}
function setAdultPrice(prx)
{
    adult_price=prx;
    document.SeatingPlanForm.fld_adult_price.value=ret2DNumber(adult_price);
}
function setChildPrice(prx)
{
    child_price=prx;
    document.SeatingPlanForm.fld_child_price.value=ret2DNumber(child_price);
}
function setStudentPrice(prx)
{
    Student_price=prx;
    document.SeatingPlanForm.fld_student_price.value=ret2DNumber(student_price);
}
function setBookingFee(prx)
{
    booking_fee=prx;
    document.SeatingPlanForm.fld_booking_fee.value=ret2DNumber(booking_fee);
}
function setPromoFee(prx)
{
    promo_fee=prx;
}


function init(pageDisplay)
{
    var msgwin;

    preloadImages();
    alerts();
    if(pageDisplay=="Shrek 2" || pageDisplay=="Shrek 2*"){
        msgwin=window.open('/Booking/shrekbelly.htm','PopupName','toolbar=0,statusbar=0, location=0,scrollbars=0,resizable=0,width=410,height=240')
    }
}

// preload the images
function preloadImages(){
    
    var i_Selected = new Image();
    i_Selected.src = stSelected;

    var i_Empty = new Image();
    i_Empty.src = stEmpty;

}


function addToSelection(seat)
{
    seats_selected=seats_selected+seat+"|";
    document.SeatingPlanForm.fld_seats_selected.value=seats_selected;
    document.SeatingPlanForm.hSeatsSelected.value=seats_selected;
}

function removeFromSelection(seat)
{
    seats_selected=seats_selected.replace(seat+"|","");
    document.SeatingPlanForm.fld_seats_selected.value=seats_selected;
    document.SeatingPlanForm.hSeatsSelected.value=seats_selected;
}
function decreaseOtherCategory(than,num)
{
    if (!hasSelector) return;
    if (than!=1 && child_num_tickets+num>=0){
        child_num_tickets=child_num_tickets+num;
        document.SeatingPlanForm.fld_child_num_tickets.value=child_num_tickets;
        return;
    }
    if (than!=2 && senior_num_tickets+num>=0){
        senior_num_tickets=senior_num_tickets+num;
        document.SeatingPlanForm.fld_senior_num_tickets.value=senior_num_tickets;
        return;
    }
    if (than!=3 && student_num_tickets+num>=0){
        student_num_tickets=student_num_tickets+num;
        document.SeatingPlanForm.fld_student_num_tickets.value=student_num_tickets;
        return;
    }
    if (than!=0 && adult_num_tickets+num>=0){
        adult_num_tickets=adult_num_tickets+num;
        document.SeatingPlanForm.fld_adult_num_tickets.value=adult_num_tickets;
        return;
    }
}
function updateTotalCost()
{
    //alert("Into updateTotalCost fn: "+promo_fee);
    if (total_num_tickets>0){
        document.SeatingPlanForm.fld_promo_price.value=ret2DNumber(adult_num_tickets*promo_fee);
        total_cost=(adult_num_tickets*adult_price+child_num_tickets*child_price+senior_num_tickets*senior_price+student_num_tickets*student_price+booking_fee+smsCharge)-(adult_num_tickets*promo_fee);
    }
    else {
        document.SeatingPlanForm.fld_promo_price.value=ret2DNumber(adult_num_tickets*promo_fee);
        total_cost=0;
    }
    if	(location_cd==imax_location_cd) { //IMAX
        if ((adult_num_tickets==2 && child_num_tickets==2) || (adult_num_tickets==1 && child_num_tickets==3)) {
            // FIX to allow for 2D movie package reduction, added 11/9/03
            if (adult_price <= 10.00){
                imax_package_tax_amount=imax_package_tax_amount_2D;
                imax_package_price=imax_package_price_2D;
            }
            // FIX End
            total_cost=imax_package_price+booking_fee;
            temp_adult_price=imax_package_price/total_num_tickets;
            temp_child_price=imax_package_price/total_num_tickets;
            document.SeatingPlanForm.hAdultTax.value=ret2DNumber(imax_package_tax_amount);
            document.SeatingPlanForm.hChildTax.value=ret2DNumber(imax_package_tax_amount);
            document.SeatingPlanForm.fld_adult_price.value=ret2DNumber(temp_adult_price);
            document.SeatingPlanForm.fld_child_price.value=ret2DNumber(temp_child_price);
        }
        else{
            document.SeatingPlanForm.fld_adult_price.value=ret2DNumber(adult_price);
            document.SeatingPlanForm.fld_child_price.value=ret2DNumber(child_price);
            document.SeatingPlanForm.hAdultTax.value=ret2DNumber(adult_tax);
            document.SeatingPlanForm.hChildTax.value=ret2DNumber(child_tax);
        }
    }
    //alert(total_cost);
    document.SeatingPlanForm.fld_total_cost.value=ret2DNumber(total_cost);
}
function updatePricePlan(num,tktt)
{
    if (total_num_tickets+num<0) {
        alert("Internal Error. Please reload the page and start a new seat selection process.");
        return;
    }
    total_num_tickets=total_num_tickets+num;
    document.SeatingPlanForm.fld_total_num_tickets.value=total_num_tickets;
    if (tktt[0].checked==1) {
        if (adult_num_tickets+num>=0){
            adult_num_tickets=adult_num_tickets+num;
            document.SeatingPlanForm.fld_adult_num_tickets.value=adult_num_tickets;
        }
        else decreaseOtherCategory(0,num);
    }
    else if (tktt[1].checked==1) {
        if (child_num_tickets+num>=0){
            child_num_tickets=child_num_tickets+num;
            document.SeatingPlanForm.fld_child_num_tickets.value=child_num_tickets;
        }
        else decreaseOtherCategory(1,num);
    }
    updateTotalCost();
}
function updatePricePlanA(num)
{
    if (total_num_tickets+num<0) {
        alert("Internal Error. Please reload the page and start a new seat selection process.");
        return;
    }


    total_num_tickets=total_num_tickets+num;
    document.SeatingPlanForm.fld_total_num_tickets.value=total_num_tickets;

    adult_num_tickets=adult_num_tickets+num;
    document.SeatingPlanForm.fld_adult_num_tickets.value=adult_num_tickets;

    updateTotalCost();
}

function changePicA(seat)
{
    if (document.images)
    {
        var i=0;
        while(document.images[i++]!=null)
        {
            if (document.images[i-1].name==seat)
            {
                if (retSS(document.images[i-1].alt)=="Free")
                {
                    if (total_num_tickets==max_tickets) {
                        alert("Sorry, you can only choose a maximum of "+max_tickets+" tickets per transaction.");
                        return;
                    }
                    else {
                        document.images[i-1].src=stSelected;
                        document.images[i-1].alt="Selected "+seat;
                        updatePricePlanA(1);
                        addToSelection(seat);
                        break;
                    }
                }
                else
                {
                    document.images[i-1].src=stEmpty;
                    document.images[i-1].alt="Free "+seat;
                    updatePricePlanA(-1);
                    removeFromSelection(seat);
                    break;
                }
            }
        }
    }
}*/





